﻿@{
    ViewBag.Title = "EduCheckIndex";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        $("#txtSchoolId").bindSelect({
            url: "/Gas/School/GetSchoolSelectJson",
        });
        $("#txtClass").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "Class" }
        });
        $("#txtStatus").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "RollOutStatus" }
        });
        gridList();
        $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center', 'vertical-align': 'middle', 'width': '50' });
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Gas/RollOutRecord/GetGridJsonByEdu",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                { label: '学生姓名', name: 'studentName', width: 150, align: 'center' },
                { label: '学生身份证号', name: 'IDNumber', width: 160, align: 'left' },
                {
                    label: "学生现所在学校", name: "SchoolId", width: 150, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.schoolItems[cellvalue] == undefined ? "" : top.clients.schoolItems[cellvalue].schoolName
                    }
                },
                {
                    label: '年级', name: 'Class', width: 100, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["Class"][cellvalue] == undefined ? "" : top.clients.dataItems["Class"][cellvalue]
                    }
                },
                {
                    label: '转入学校名称', name: 'InSchoolName', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.schoolItems[cellvalue] == undefined ? "" : top.clients.schoolItems[cellvalue].schoolName
                    }
                },
                { label: '办理人姓名', name: 'TransactorName', width: 100, align: 'left' },
                {
                    label: '办理人与学生关系', name: 'TransactorRelation', width: 120, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["TransactorRelationItem"][cellvalue] == undefined ? "" : top.clients.dataItems["TransactorRelationItem"][cellvalue]
                    }
                },
                { label: '学生转出离校时间', name: 'RollOutDate', width: 110, align: 'left' },
                {
                    label: '转出申请状态', name: 'status', width: 150, align: 'center',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["RollOutStatus"][cellvalue] == undefined ? "" : top.clients.dataItems["RollOutStatus"][cellvalue]
                    }
                },
                { label: '备注', name: 'Content', width: 150, align: 'left' },
                {
                    label: "操作", name: "F_Id", width: 350, align: "left",
                    formatter: function (cellvalue) {
                        return "<div class='btn-group' style='background-color:#1ABC9C;'><a class='btn btn-primary' onclick=\"btn_check('" + cellvalue + "')\"><i class='fa fa-edit'></i>审核</a></div>" +
                            "<div class='btn-group' style='background-color:#1ABC9C;margin-left:5px'><a class='btn btn-primary' onclick=\"btn_delete('" + cellvalue + "')\"><i class='fa fa-trash-o'></i>删除</a></div>";
                    }
                },
            ],
            pager: "#gridPager",
            sortname: 'SchoolId asc',
            viewrecords: true,
            multiselect: true,
            loadComplete: function (xhr) {
                for (var i = 0, l = xhr.rows.length; i < l; i++) {
                    var objId = "#jqg_gridList_" + xhr.rows[i].F_Id;
                    $(objId).removeClass('checkbox');
                    $(objId).css('vertical-align', 'middle');
                }
            }
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { schoolId: $("#txtSchoolId").val(), classValue: $("#txtClass").val(), status: $("#txtStatus").val()},
            }).trigger('reloadGrid');
        });
        $("#btn_admit").click(function () {
            var selId = $("#gridList").jqGrid('getGridParam', 'selarrrow').join(",");
            if (null != selId && "" != selId) {
                $.ajax({
                    url: "/Gas/RollOutRecord/MultiUpdate?selId=" + selId,
                    success: function (data) {
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                    }
                });
            } else {
                bootbox.alert("请选择想要审核的数据");
                return;
            }
        });
    }
    function btn_check(obj) {
        if (obj == null || obj == "" || obj == "undefined" ) {
            bootbox.alert("请选择想要审核的数据");
            return;
        }
        $.modalOpen({
            id: "Update",
            title: "信息修改",
            url: "/Gas/RollOutRecord/EduCheckForm?keyValue=" + obj,
            width: "800px",
            height: "650px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();//提交表单
            }
        });
    }
    function btn_delete(obj) {
        $.deleteForm({
            url: "/Gas/RollOutRecord/DeleteForm",
            param: { keyValue: obj },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <select id="txtSchoolId" class="form-control" style="width:110px"></select>
                        <select id="txtClass" class="form-control" style="width:120px">
                            <option value="">请选择年级</option>
                        </select>
                        <select id="txtStatus" class="form-control" style="width:120px">
                            <option value="">请选择申请状态</option>
                        </select>
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                        <span class="input-group-btn" style="padding-left:20px">
                            <button id="btn_admit" type="button" class="btn  btn-primary"><i class="fa fa-child">&nbsp;&nbsp;批量审核</i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
<div id="my-modal" class="modal fade" data-placement="center" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>